package com.ruoyi.yyq.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.yyq.domain.CarServiceType;
import com.ruoyi.yyq.service.ICarServiceTypeService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 服务类型Controller
 * 
 * @author ruoyi
 * @date 2025-05-10
 */
@RestController
@RequestMapping("/fuwutype")
@CrossOrigin
public class CarServiceTypeController extends BaseController
{
    @Autowired
    private ICarServiceTypeService carServiceTypeService;

    /**
     * 查询服务类型列表
     */
    @RequiresPermissions("yyq:fuwutype:list")
    @GetMapping("/list")
    public TableDataInfo list(CarServiceType carServiceType)
    {
        startPage();
        List<CarServiceType> list = carServiceTypeService.selectCarServiceTypeList(carServiceType);
        return getDataTable(list);
    }

    /**
     * 导出服务类型列表
     */
    @RequiresPermissions("yyq:fuwutype:export")
    @Log(title = "服务类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CarServiceType carServiceType)
    {
        List<CarServiceType> list = carServiceTypeService.selectCarServiceTypeList(carServiceType);
        ExcelUtil<CarServiceType> util = new ExcelUtil<CarServiceType>(CarServiceType.class);
        util.exportExcel(response, list, "服务类型数据");
    }

    /**
     * 获取服务类型详细信息
     */
    @RequiresPermissions("yyq:fuwutype:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(carServiceTypeService.selectCarServiceTypeById(id));
    }

    /**
     * 新增服务类型
     */
    @RequiresPermissions("yyq:fuwutype:add")
    @Log(title = "服务类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CarServiceType carServiceType)
    {
        return toAjax(carServiceTypeService.insertCarServiceType(carServiceType));
    }

    /**
     * 修改服务类型
     */
    @RequiresPermissions("yyq:fuwutype:edit")
    @Log(title = "服务类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CarServiceType carServiceType)
    {
        return toAjax(carServiceTypeService.updateCarServiceType(carServiceType));
    }

    /**
     * 删除服务类型
     */
    @RequiresPermissions("yyq:fuwutype:remove")
    @Log(title = "服务类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(carServiceTypeService.deleteCarServiceTypeByIds(ids));
    }
}
